import java.util.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class Test08 {
    public static void main(String[] args) {
        ArrayList<String> list=new ArrayList<>();
        Collections.addAll(list,"张无忌-男-15","周芷若-女-14","赵敏-女-13","张强-男-20","张三丰-男-100","张翠山-男-35");
        /*list.stream().filter(new Predicate<String>(){
            @Override
            public boolean test(String s){
                String[] arr=s.split("-");
                return arr[1].equals("男");
            }
        }).forEach(new Consumer<String>(){
            @Override
            public void accept(String s){
                System.out.println(s);
            }
        });*/
        list.stream().filter(s->(s.split("-")[1].equals("男")))
                .forEach(s->System.out.println(s));
        List<String> newList=list.stream().filter(new Predicate<String>(){
            @Override
            public boolean test(String s){
                String[] arr=s.split("-");
                return arr[1].equals("男");
            }
        }).collect(Collectors.toList());
        System.out.println(newList);
        Set<String> newSet=list.stream().filter(s->(s.split("-")[1].equals("男")))
                .collect(Collectors.toSet());
        System.out.println(newSet);
        Map<String,Integer> map=list.stream().filter(new Predicate<String>(){
            @Override
            public boolean test(String s){
                String[] arr=s.split("-");
                return arr[1].equals("男");
            }
        }).collect(Collectors.toMap(s->s.split("-")[0],s->Integer.parseInt(s.split("-")[2])));
        System.out.println(map);

    }
}
